package errs

import (
	"net/http"
)

var (
	ErrConcurrency = NewConflict("concurrency error, the data has been modified. Please try again")
)

type Error struct {
	Code    int
	Message string
}

func (e Error) Error() string {
	return e.Message
}

func New(code int, message string) error {
	return Error{
		Code:    code,
		Message: message,
	}
}

func NewBadRequest(message string) error {
	return New(http.StatusBadRequest, message)
}

func NewUnauthorized(message string) error {
	return New(http.StatusUnauthorized, message)
}

func NewForbidden(message string) error {
	return New(http.StatusForbidden, message)
}

func NewNotFound(message string) error {
	return New(http.StatusNotFound, message)
}

func NewInternalServerError(message string) error {
	return New(http.StatusInternalServerError, message)
}

func NewConflict(message string) error {
	return New(http.StatusConflict, message)
}
